package com.udi.project.business.test;


import com.alibaba.fastjson.JSONObject;
import com.udi.project.business.utils.httpApi.OkHttp1;
import okhttp3.FormBody;
import okhttp3.RequestBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;

/**
 * @author Admin
 * 测试
 */
@Controller
@RequestMapping("/test")
public class TemporarilyController {

    @Autowired
    private OkHttp1 okHttp1;



    /**
     * http://localhost:8080/test/getToken
     *
     * */
    @GetMapping("/getToken")
    @ResponseBody
    public JSONObject testOkhttp() throws IOException {
        String appId = "dc441f02955047b9a41fdc99587bd84e";
        String appSecret = "de9870ca80bf4a459d98542c7f679a14";


        String str = "{\"appId\":\""+appId+"\",\"appSecret\":\""+appSecret+"\"}";
        RequestBody requestBody = new FormBody.Builder()
                .add("params",str)
                .build();
        return okHttp1.PostOkHttp("https://udid.nmpa.gov.cn/api/v1/token/get",requestBody);

    }
}
